﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Xml;
using System.IO;
using System.Text;
using System.Data;
namespace pcsse.WebService
{
    /// <summary>
    /// Summary description for PublicService
    /// </summary>
    [WebService(Namespace = "http://sse.tongji.edu.cn/spb/p")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class PublicService : System.Web.Services.WebService
    {
        


        [WebMethod(Description="获得最新10条党支部信息XML格式列表")]
        public string GetArticleList()
        {
            DataTable dt = db_news.getDBhandle().GetDataTableBySQL("SELECT TOP 10 * FROM T_NEWS LEFT JOIN T_CATEGORY ON T_NEWS.CATEGORY_ID = T_CATEGORY.CATEGORY_ID WHERE PERMISSION = 1 ORDER BY NEWS_ID DESC");

            System.IO.MemoryStream newslist = new System.IO.MemoryStream();


            XmlTextWriter writer = new XmlTextWriter(newslist, System.Text.Encoding.UTF8);

            foreach (DataRow dr in dt.Rows)
            {
                
                writer.WriteStartElement("article");
                writer.WriteElementString("title", dr["TITLE"].ToString());
                writer.WriteElementString("description",dr["TEXT_CONTENT"].ToString());
                writer.WriteElementString("pubDate", dr["Date"].ToString());
                writer.WriteEndElement();
            }


            writer.Flush();
            writer.Close();

            return System.Text.Encoding.UTF8.GetString(newslist.ToArray());
           

        }

        [WebMethod(Description = "根据身份证号查询人员信息")]
        public string GetAuthority(string IDNUMBER)
        {
            return null;
        }


      


    }
}
